package com.tulele.vtool.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;
import com.tulele.vtool.mapper.BBusinessDetailsMapper;
import com.tulele.vtool.model.BBusinessDetails;
import com.tulele.vtool.service.BBusinessDetailsService;

import javax.annotation.Resource;
import java.util.List;

/**
 * 商学院课程详情信息表(BBusinessDetails)表服务实现类
 *
 * @author makejava
 * @since 2020-10-22 15:35:26
 */
@Service("bBusinessDetailsService")
public class BBusinessDetailsServiceImpl implements BBusinessDetailsService {
    @Resource
    private BBusinessDetailsMapper bBusinessDetailsMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public BBusinessDetails queryById(Integer id) {
        return this.bBusinessDetailsMapper.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<BBusinessDetails> queryAllByLimit(int offset, int limit) {
        return this.bBusinessDetailsMapper.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param bBusinessDetails 实例对象
     * @return 实例对象
     */
    @Override
    public BBusinessDetails insert(BBusinessDetails bBusinessDetails) {
        this.bBusinessDetailsMapper.insert(bBusinessDetails);
        return bBusinessDetails;
    }

    /**
     * 修改数据
     *
     * @param bBusinessDetails 实例对象
     * @return 实例对象
     */
    @Override
    public BBusinessDetails update(BBusinessDetails bBusinessDetails) {
        this.bBusinessDetailsMapper.update(bBusinessDetails);
        return this.queryById(bBusinessDetails.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.bBusinessDetailsMapper.deleteById(id) > 0;
    }

    /**
     * 查询多条数据
     *
     * @param pageNum 查询起始位置
     * @param pageSize  查询条数
     * @param bBusinessDetails 实例对象
     * @return 对象列表
     */
    @Override
    public PageInfo selectAllByLimit(Integer pageNum, Integer pageSize, BBusinessDetails bBusinessDetails) {

        PageHelper.startPage(pageNum, pageSize);

        List<BBusinessDetails> bBusinessDictList = this.bBusinessDetailsMapper.queryAll(bBusinessDetails);

        return new PageInfo<BBusinessDetails>(bBusinessDictList);
    }
}